#ifndef _DAO_H
#define _DAO_H

// 数据结构体
#include "list.h"

#define ADMIN_FILE "../data/admin.dat"
#define USER_FILE "../data/user.dat"
#define TEMP_FILE "../data/tmp.dat"
#define SECRET "**2021**"
#define MAX_USERNAME_LENGTH 20
#define MAX_PASSWORD_LENGTH 20
#define MAX_USER_COUNT 100

// Admin 结构体
typedef struct Admin
{
    int id;
    char account[20];
    char passwd[20];
    char gender; // woman/man
} Admin;

// User结构体
typedef struct User
{
    int id;
    char name[20];
    char passwd[20];
    int score;
    char gender;
} User;

typedef enum
{
    Error = -1,
    NameError,
    PassError,
    IsLock,
    LoginOk
} State;

#define ADMIN_SIZE sizeof(Admin)
#define USER_SIZE sizeof(User)

// 存储到文件的结构体
size_t load(List* list, const char* path, int length);
size_t save(List* list, const char* path, int length);

#endif
